public class CheckRecord {

    public boolean checkRecord(String s) {
        int countA = 0;
        int countL = 0;
        char[] chars = s.toCharArray();
        for (int i = 0; i < s.length(); i++) {
            if (chars[i] == 'A') {
                ++countA;
                countL = 0;
            } else if (chars[i] == 'L') {
                ++countL;
            } else countL = 0;
            if (countA >= 2 || countL >= 3) return false;
        }
        return true;
    }
}
